% by YLX 6/9 
% update to 2.3 
function Q = findQ(S)
    global I 
    m_max = max(sum(S, 2)); % sum of dimention 2 (row)
    Q = zeros(I, m_max);
    for i = 1:I
        patient_num_i = sum(S(i, :));
        for m = 1:m_max
            if m > patient_num_i
                % Q(i, m) = -1;
                % ? 当 slot i的总人数小于 m_max 时, m 大于总人数的部分如何处理？
                % 是否认为概率为 0 即可
                break;
            else
                Q(i, m) = elementQ(S, i, m);
            end
        end
    end

    return;